<script setup>
import { ref, defineEmits } from 'vue'
import { enterpriseUpdateNoteService } from '@/api/enterprise'

const emit = defineEmits(['refresh'])
const isVisible = ref(false)

let note = ref('')
/*打开弹窗*/
let informationId = null
const openNote = async (id, newNote) => {
  isVisible.value = true
  note.value = newNote
  informationId = id
}
/*修改备注*/
const updatedNote = async () => {
  await enterpriseUpdateNoteService({ informationId, note: note.value })
  emit('refresh')
  isVisible.value = false
  note.value = {} //清空
  informationId = null
}
/*取消*/
const quitNote = () => {
  isVisible.value = false
  note.value = {} //清空
  informationId = null
}
defineExpose({
  openNote
})
</script>

<template>
  <el-dialog v-model="isVisible" title="content:" width="600">
    <el-form-item>
      <el-input
        type="textarea"
        :rows="10"
        class="note-part"
        v-model="note"
        autocomplete="off"
      />
    </el-form-item>
    <template #footer>
      <div class="dialog-footer">
        <el-button color="#626aef" :dark="isDark" round @click="quitNote"
          >取消
        </el-button>
        <el-button color="#626aef" :dark="isDark" round @click="updatedNote"
          >确认
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>
<style>
.el-dialog {
  border-radius: 20px;
}
.dialog-footer {
  display: flex;
  justify-content: center;
  .el-button {
    width: 100px;
    margin: 0 50px;
  }
}
</style>
